import { Component, OnInit, Renderer } from '@angular/core';
import { GoodService } from './../vsp/bean';
import { ActivatedRoute, ParamMap, Router, NavigationEnd } from '@angular/router';
import 'rxjs/add/operator/switchMap';
@Component({
  selector: 'app-good',
  templateUrl: './good.component.html',
  styleUrls: ['./good.component.css'],
  providers: [GoodService]
})
export class GoodComponent implements OnInit {
  goodinfos: any;
  goodid: string;
  constructor(
    private goodService: GoodService,
    private route: ActivatedRoute,
    private router: Router,
    private renderer: Renderer
  )
  { }

  ngOnInit() {
    this.renderer.setElementProperty(document.body, "scrollTop", 0);
    let id = this.route.snapshot.paramMap.get('id');
    this.goodService.getGood(id).then(res => {
      this.goodinfos = res.json().data;
      this.goodinfos.finalPrice = this.goodinfos.goodsPrice - this.goodinfos.couponPrice;
      this.goodid = this.goodinfos.goodsId;
    });
   
  }
}

